//
//  RoomCommentHeaderView.m
//  YJRenter
//
//  Created by 文彬 on 2018/7/12.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "RoomCommentHeaderView.h"
#import "MakeScoreView.h"

@interface RoomCommentHeaderView()

@property (strong, nonatomic) UIView *countBgView;
@property (strong, nonatomic) UILabel *scoreLabel;
@property (strong, nonatomic) UILabel *countLabel;
@property (strong, nonatomic) MakeScoreView *healthScoreView;
@property (strong, nonatomic) MakeScoreView *serviceScoreView;
@property (strong, nonatomic) MakeScoreView *landlordScoreView;
@property (strong, nonatomic) MakeScoreView *facilityScoreView;

@end

@implementation RoomCommentHeaderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self initControl];
    }
    return self;
}

- (id)init{
    self = [super init];
    if (self) {
        
        [self initControl];
        
   
    }
    return self;
}

- (void)initControl{
    
    self.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:self.countBgView];
    [self addSubview:self.scoreLabel];
    [self addSubview:self.countLabel];
    [self addSubview:self.healthScoreView];
    [self addSubview:self.serviceScoreView];
    [self addSubview:self.landlordScoreView];
    [self addSubview:self.facilityScoreView];
    
    [self setData];

}

- (void)layoutSubviews{
    [self.countBgView makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@120);
        make.centerX.equalTo(self.centerX);
        make.top.equalTo(@30);
    }];
    [self.scoreLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.countBgView.left);
        make.right.equalTo(self.countBgView.right);
        make.height.equalTo(@30);
        make.top.equalTo(self.countBgView.top).offset(15);
    }];
    [self.countLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.scoreLabel.left);
        make.right.equalTo(self.scoreLabel.right);
        make.height.equalTo(@30);
        make.top.equalTo(self.scoreLabel.bottom).offset(5);
    }];
    [self.healthScoreView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.width.equalTo(@150);
        make.height.equalTo(@40);
        make.top.equalTo(self.countBgView.bottom).offset(10);
    }];
    
    [self.landlordScoreView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.width.equalTo(@150);
        make.height.equalTo(@40);
        make.top.equalTo(self.healthScoreView.bottom).offset(10);
    }];
    
    [self.serviceScoreView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.centerX).offset(20);
        make.width.equalTo(@150);
        make.height.equalTo(@40);
        make.centerY.equalTo(self.healthScoreView.centerY);
    }];
    
    [self.facilityScoreView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.serviceScoreView.left);
        make.width.equalTo(@150);
        make.height.equalTo(@40);
        make.centerY.equalTo(self.landlordScoreView.centerY);
    }];
}

- (void)setData{
    self.scoreLabel.text = @"5.0";
    self.countLabel.text = @"(共60条)";
}
#pragma mark getter
- (UIView*)countBgView{
    if (_countBgView==nil) {
        _countBgView = [[UIView alloc]init];
        _countBgView.backgroundColor = kMainOriginColor;
        _countBgView.layer.cornerRadius = 4;
    }
    return _countBgView;
}

- (UILabel*)scoreLabel{
    if (_scoreLabel==nil) {
        _scoreLabel = [[UILabel alloc]init];
        _scoreLabel.textColor = [UIColor whiteColor];
        _scoreLabel.font = [UIFont boldSystemFontOfSize:25];
        _scoreLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _scoreLabel;
}
- (UILabel*)countLabel{
    if (_countLabel==nil) {
        _countLabel = [[UILabel alloc]init];
        _countLabel.textColor = [UIColor whiteColor];
        _countLabel.font = [UIFont systemFontOfSize:16];
        _countLabel.textAlignment = NSTextAlignmentCenter;
        _countLabel.adjustsFontSizeToFitWidth = YES;
    }
    return _countLabel;
}
- (MakeScoreView*)healthScoreView{
    if (_healthScoreView==nil) {
        _healthScoreView = [[MakeScoreView alloc]init];
        _healthScoreView.titleLabel.text = @"整洁卫生";
        _healthScoreView.starSpace = 2;
        _healthScoreView.starWidth = 16;
    }
    return _healthScoreView;
}

- (MakeScoreView*)serviceScoreView{
    if (_serviceScoreView==nil) {
        _serviceScoreView = [[MakeScoreView alloc]init];
        _serviceScoreView.titleLabel.text = @"管理服务";
        _serviceScoreView.starSpace = 2;
        _serviceScoreView.starWidth = 16;
    }
    return _serviceScoreView;
}

- (MakeScoreView*)landlordScoreView{
    if (_landlordScoreView==nil) {
        _landlordScoreView = [[MakeScoreView alloc]init];
        _landlordScoreView.titleLabel.text = @"房东服务";
        _landlordScoreView.starSpace = 2;
        _landlordScoreView.starWidth = 16;
    }
    return _landlordScoreView;
}

- (MakeScoreView*)facilityScoreView{
    if (_facilityScoreView==nil) {
        _facilityScoreView = [[MakeScoreView alloc]init];
        _facilityScoreView.titleLabel.text = @"设施环境";
        _facilityScoreView.starSpace = 2;
        _facilityScoreView.starWidth = 16;
    }
    return _facilityScoreView;
}

@end
